Page({
  data: {
    respData: '',
  },
  onLoad: function (options) {
    var wxCode = '';
    wx.login({
      success: res => {
        console.log(res.errMsg + "," + res.code)
        console.log('发送 res.code 到后台换取 openId, sessionKey, unionId')
        this.setData({
          wxCode: res.code,
        });
        var that = this;
        var app = getApp();
        console.log('Url-member=' + options.memNum);
        if (options.memNum != null) {
          var memNum = options.memNum;
        } else {
          wx.showLoading({
            title: '系统错误'
          });
        }
        that.setData({
          memberNum: memNum,
        });
        wx.showLoading({
          title: '数据加载中'
        });
        //请求后台数据
        that.requestData()
      },
      fail: function () {
        wx.showModal({
          title: '提示',
          content: "获取用户信息失败！",
          showCancel: false
        })
      }
    })

  },
  requestData: function () {
    var that = this;
    wx.request({
      url: app.globalData.mpurl + 'share/member/' + that.data.memberNum,
      method: "GET",
      data: {
        wxCode: that.data.wxCode,
        memberNum: that.data.memberNum,
      },
      success: function (res) {
        console.log(":" + that.data.wxCode);
        res = res.data;
        if (res.code == '00') {
          that.setData({ respData: res.data });
        } else {
          wx.showModal({
            title: '提示',
            content: '获取信息失败',
            showCancel: false,
          })
        }
      },
      fail: function (res) {
        wx.showModal({
          title: '提示',
          content: "系统异常，请稍候再试",
          showCancel: false
        })
      },
      complete: function () {
        wx.hideLoading();
      }
    });
  },
    calling: function (e) {
    var mobileNum = e.currentTarget.dataset.mobile;
    wx.makePhoneCall({
      phoneNumber: mobileNum,
      success: function () {
        console.log("拨打电话成功！")
      },
      fail: function () {
        console.log("拨打电话失败！")
      }
    })
  },
  bindTextAreaBlur: function (e) {
    console.log(e.detail.value)
  },
  onReady: function () {
    console.log("this.data.respData.introduce:" + this.data.respData.introduce)
    this.setData({
      introduce: this.data.respData.introduce,
      address: this.data.respData.site
    })
    console.log('var that = this;')
  },
  onShow: function (e) {
    wx.setNavigationBarTitle({
      title: '手机群录',
    })
  },
  changeNavi: function () {
    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: '#ff0000',
      animation: {
        duration: 400,
        timingFunc: 'easeIn'
      }
    })
  },
  onShareAppMessage: function () {
    return {
      title: '手机群录',
      imageUrl: 'http://sta.haois.me/common/img/shareapp.png',
      path: '/pages/shareMem/share?memNum=' + this.data.respData.memberNum,
      success: function (res) {
        console.log('转发成功');
      },
      fail: function (res) {
        console.log('转发失败');
      }
    }

  }
})
